package cn.toesbieya.jxc.service;

import cn.toesbieya.jxc.model.vo.statictis.FourBlockStat;
import cn.toesbieya.jxc.util.WebSocketUtil;
import cn.toesbieya.jxc.util.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class StatisticService {

    //获取首页四个色块的数据，在线用户
    public FourBlockStat getFourBlock() {
        long now = DateUtil.getTimestampNow();

        FourBlockStat stat = new FourBlockStat();

        long onlineNum = WebSocketUtil.getOnlineUserNum();

        stat.setOnline(onlineNum == 0L ? 1L : onlineNum);//进行此请求时在线用户必然大于0

        return stat;
    }
}
